package durose.durose;

import java.util.List;

import durose.system.pojo.DuRose;

public class DuRoseGeneratorJs {
		public static String initColumnName(List<DuRose> duroses){
			StringBuffer sb = new StringBuffer();
			for(DuRose durose:duroses){
				sb.append(initColumnName(durose)+"\n");
			}
			return sb.toString();
		}
	
		public static String initColumnName(DuRose durose){
			if(durose.getColumnType().equals("picture")){
				String str = "htmlStr+='<td><img class=\"rounded mr-2\" onerror=src=\"static/images/users/avatar-1.jpg\" alt=\"\" style=\"width: 128px; height: 128px;\" src=\"static/img/'+data[i]."+durose.getColumnName()+"+'\"></td>'";
				return str;
			}else if(durose.getColumnType().equals("date")){
				String str= "htmlStr+='<td>'+initDate(data[i]."+durose.getColumnName()+")+'</td>'";
				return str;
			}else{
				String str = "htmlStr+='<td>'+data[i].$columnName$+'</td>'";
				str = str.replace("$columnName$", durose.getColumnName());
				return str;
			}
		}
}
